package com.work.yly.website.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.work.yly.website.service.ServiceDefine;
import com.work.yly.website.service.ServiceHelper;

import net.sf.json.JSONObject;

@Controller
@RequestMapping("/loan")
public class LoanController extends BaseController {
	@RequestMapping("/index")
	public String index() {
		return "/loan/index";
	}

	@RequestMapping("/iwantjk")
	public String wantloan(HttpServletRequest request){
		HttpSession session = request.getSession();
		Object zh_id = session.getAttribute("zh_id");
		//Object hy_id = session.getAttribute("hy_id");
		String jklx = request.getParameter("jklx");
		if (null != zh_id) {
			JSONObject ret = ServiceHelper.getZlWsqk(Integer.valueOf(zh_id.toString()));
			if(ret.getInt("flag")==ServiceDefine.CALL_SUCCESS){
				if(!ret.getJSONObject("data").getBoolean("allBas")){
					return "redirect:../my/hyxx?dojk=1&jklx="+jklx;
				}
				else{
					return "redirect:../my/hyxx?dojk=1&flag="+jklx+"&jklx="+jklx;
				}
			}
			else{
				return "";
			}
		}
		else{
			return "redirect:../login?successUrl=/loan/iwantjk";
		}
	}

}
